home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swaga_c.zip / CRT.SWG / 0026_Stop Screen Output.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-03  |  2KB  |  59 lines

  1. {
  2.  JP> I've got a problem. I'm writing a program that uses a lot of
  3.  JP> compression programs with just a simple shell command. It
  4.  JP> works fine with all of them except from LHA. I execute the
  5.  JP> the line 'LHA E FILENAME.LZH BAH.TXT >NUL', and the '>NUL'
  6.  JP> is enough for all the others, thou not LHA. It still writes
  7.  JP> a lot of crap to the screen. How do I prevent this ?
  8.  
  9. With the following technique:
  10. }
  11.  
  12. Program PreventFromScreenOutput;
  13. { Written by Andrew Eigus of 2:5100/33 or andrew@cs.rau.lv }
  14. { Public domain, source that runs any program and prevents it from output
  15.   to a screen }
  16.  
  17. {$M $4000,0,0} { 16k stack, no heap }
  18.  
  19. uses Dos;
  20.  
  21. Procedure NewInt10Vector; interrupt; assembler;
  22. { This is a simple IRET instruction to all of Int 10h functions }
  23. Asm
  24. End; { NewInt10Vector }
  25.  
  26. Procedure Execute(Command : string);
  27. var OldInt10Vector : pointer;
  28. Begin
  29.   if Command <> '' then
  30.     Command := '/C ' + Command + ' >nul' else Exit;
  31.   GetIntVec($10, OldInt10Vector);
  32.   SetIntVec($10, @NewInt10Vector);
  33.   SwapVectors;
  34.   Exec(GetEnv('COMSPEC'), Command);
  35.   SwapVectors;
  36.   if DosError <> 0 then
  37.     WriteLn('Bad command or file name');
  38.   SetIntVec($10, OldInt10Vector)
  39. End; { Execute }
  40.  
  41. var Command : ComStr;
  42.  
  43. Begin
  44.   if ParamCount > 0 then
  45.     Command := ParamStr(1)
  46.   else
  47.   begin
  48.     Write('Enter command or file name: ');
  49.     ReadLn(Command);
  50.   end;
  51.   Execute(Command)
  52. End.
  53.  
  54.  
  55. BTW, it even runs gfx programs and runs with no screen output! And tested with
  56. LHA. It temporary eliminates the video bios support (Int 10h) thus preventing
  57. hardware writes to the screen. It is quite a rude approach but it works!
  58.  
  59.